Two Windows 11 machines shared a Desktop
folder under OneDrive
. A couple of the Shortcut
files in the folder, valid links to applications, were missing their icons. The problem was fixed by forcing the rebuilding the icon cache.
Rebuilding the icon cache
The rebuilding of the icon cache can be forced, as follows (in PowerShell):
1 2 3 4 5 6 |
Stop-Process -Name explorer -Force $iconCachePath1 = "$env:LOCALAPPDATA\IconCache.db" $iconCachePath2 = "$env:LOCALAPPDATA\Microsoft\Windows\Explorer\iconcache*" Remove-Item $iconCachePath1 -ErrorAction SilentlyContinue -Force Remove-Item $iconCachePath2 -ErrorAction SilentlyContinue -Force Start-Process explorer.exe |
The Stop-Process
cmdlet stops a running process. The -Force
parameter allows that to happen without prompting for confirmation.
The Remove-Item
cmdlet deletes the specified item at parameter position 0 (or specified by the -Path
parameter). The -ErrorAction
parameter determines how the cmdlet responds to a non-termination error; SilentlyContinue
suppresses the error message and continues executing the command. The -Force
parameter allows the removal of items that can’t otherwise be changed.
The Start-Process
cmdlet starts a process with the specified file of the program that runs in the process at parameter position 0 (or specified by the -FilePath
parameter).
A reboot was required to cause $Env:LOCALAPPDATA\IconCache.db
to be recreated.